package com.example.administrator.wallet.adapter;

import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.wallet.R;

import java.util.List;

/**
 * Effect:
 * <p>
 * Author:  CaiYapeng
 * <p>
 * Time  :  2018/8/16.
 */
public class FindListItem2Adapter extends BaseAdapter {
    private Activity context;
    private List<Integer> item_one_icon;
    private List<String> item_one_title;

    public FindListItem2Adapter(Activity context, List<Integer> item_one_icon, List<String> item_one_title) {
        this.context = context;
        this.item_one_icon = item_one_icon;
        this.item_one_title = item_one_title;
    }

    @Override
    public int getCount() {
        return item_one_title.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
            ViewHolder holder;
        if(view==null){
            view=View.inflate(context, R.layout.item_find_list_grid,null);
            holder=new ViewHolder();
            view.setTag(holder);
        }else{
            holder= (ViewHolder) view.getTag();
        }
        holder.mLinear= (LinearLayout) view.findViewById(R.id.mLinear);
        holder.item_title = (TextView) view.findViewById(R.id.item_title);
        holder.item_icon =(ImageView) view.findViewById(R.id.item_icon);

        holder.item_icon.setImageResource(item_one_icon.get(i));
        holder.item_title.setText(item_one_title.get(i));

        holder.mLinear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                switch (i){
                    case 0:
                        Log.e("TAG",item_one_title.get(i));
                        break;
                }
            }
        });

        return view;
    }

    public class ViewHolder {
        LinearLayout mLinear;
        ImageView item_icon;
        TextView item_title;
    }
}
